<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8" />
    <title>忘记密码</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no,email=no,address=no" />
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
    <link rel="stylesheet" href="../css/common.css" />
    <link rel="stylesheet" href="../css/y_index.css" />
</head>

<body class="bw">
    <article>
        <div class="ptb120 tac">
            <img src="../img/logo.png" style="width: 3.5rem;">
        </div>
        <div class="plr50">
            <label class="plr20 bdb ptb30 flex_a">
                <img src="../img/ico1.png" style="width: .3rem;">
                <input type="number" class="ml20 flex1" placeholder="请输入手机号码" id="phone" />
            </label>
            <div class="plr20 bdb flex_sb">
                <label class="flex_a ptb30">
                    <img src="../img/ico3.png" style="width: .3rem;">
                    <input type="password" class="ml20 flex1" placeholder="请输入您的验证码" id="code" />
                </label>
                <button class="border-r6 getCode">获取验证码</button>
            </div>
            <label class="plr20 bdb ptb30 flex_a">
                <img src="../img/ico2.png" style="width: .3rem;">
                <input type="password" class="ml20 flex1" placeholder="请输入您的新密码" id="psw" />
            </label>
            <label class="plr20 bdb ptb30 flex_a">
                <img src="../img/ico2.png" style="width: .3rem;">
                <input type="password" class="ml20 flex1" placeholder="请再次输入您的新密码" id="n_psw" />
            </label>
        </div>
        <div class="flex_aj">
            <button class="bgc1 colw lh80 border-r6 plr110 btn_tap mt60">登录</button>
        </div>
    </article>
</body>

</html>
<script src="../js/jquery-1.8.3.min.js"></script>
<script src="../js/dlc.js"></script>
<script>
var onOff = 0;
$(function() {
    /********验证码********/
    $(".getCode").on('click', function() {
        var phone = $('#phone').val();
        if (isNull(phone)) {
            dlctipbox.show("请输入手机号");
        } else if (!checkMobileAndTel(phone)) {
            dlctipbox.show("手机号码有误");
        } else {
            var second = 60;
            var t = setInterval(function() {
                if (second <= 0) {
                    second = 0;
                    $(".getCode").text("重发验证码");
                    $(".getCode").attr("disabled", false).css('color', '#322c25');
                    clearInterval(t);
                } else {
                    second--;
                    $(".getCode").attr("disabled", true);
                    $(".getCode").text(second + "s").css('color', '#ccc');
                }
            }, 1000);

            dlc_request('/api/agent/sendCode', { phone: phone }, function(res) {
                if (res.code == 1) {
                    dlctipbox.show('验证码发送成功');
                } else {
                    dlctipbox.show(res.msg);
                }
            })
        }
    });
    //确定
    $('.btn_tap').click(function() {
        var phone = $('#phone').val();
        var code = $('#code').val();
        var psw = $('#psw').val();
        var n_psw = $('#n_psw').val();
        if (isNull(phone)) {
            dlctipbox.show('请输入手机号码');
        } else if (!checkMobileAndTel(phone)) {
            dlctipbox.show('手机号码有误');
        } else if (isNull(code)) {
            dlctipbox.show('请输入您的验证码');
        } else if (isNull(psw)) {
            dlctipbox.show('请输入您的新密码');
        } else if (isNull(n_psw)) {
            dlctipbox.show('请再次输入您的新密码');
        } else if (n_psw != psw) {
            dlctipbox.show('两次输入的密码不一致');
        } else {
            if (onOff) return false;
            onOff = 1;
            dlctipbox.loading('请稍后');
            dlc_request('/api/agent/forgetPassword', { phone: phone, password: psw, phoneCode: code, rePassword: n_psw }, function(res) {
                dlctipbox.clear();
                console.log(res);
                if (res.code == 1) {
                    dlctipbox.alert('修改成功', function(flag) {
                        if (flag == 1) {
                            history.go(-1);
                        }
                    })
                } else {
                    onOff = 0;
                    dlctipbox.alert(res.msg);
                }
            })
        }

    })
})
</script>